﻿<link href="http://cloud.youku.com/assets/lib/bootstrap2.1.0/css/bootstrap.css" rel="stylesheet">
<link href="http://cloud.youku.com/assets/lib/bootstrap2.1.0/css/bootstrap-responsive.css" rel="stylesheet">
<style>
    .uploadfile {
        width: 150px;
        height: 14px;
        vertical-align: top;
    }
</style>
<script src="http://cloud.youku.com/assets/lib/jquery-1.8.1.min.js"></script>
<script src="http://cloud.youku.com/assets/lib/uploadjs.php"></script>

<script>
    //document.domain = "youku.com";
    var USE_STREAM_UPLOAD = true;
    jQuery(document).ready(function () {
         <?php if(!empty($videoModel)){?>
        $.post("https://openapi.youku.com/v2/oauth2/token", { "client_id": "<?php echo $videoModel->client_id ?>", "client_secret": "<?php echo $videoModel->client_secret ?>", "grant_type": "refresh_token", "refresh_token": "<?php echo $videoModel->refresh_token ?>" }, function (data, textStatus) {
            alert(data.access_token);
            if (textStatus == "success") {
                var param = { client_id: "<?php echo $videoModel->client_id ?>", access_token: data.access_token, oauth_opentype: "iframe", oauth_redirect_uri: "/youkuupload/oauth_result.html", oauth_state: "", completeCallback: "uploadComplete", categoryCallback: "categoryLoaded" };
                youkuUploadInit(param);
            }

        })
        <?php } else {?>

        if (confirm("视频基本信息为完善，是否去完善")) {
            parent.window.location.href = "/VideoSet/VideoSetInfo/94";
        }
        else {

        }
         <?php }?>

    });

    function uploadComplete(data) {
        //alert("videoid=" + data.videoid + ";title=" + data.title);
        parent.SetVideoIdValue("<?php echo $videoModel->client_id ?>", data.videoid);
        uploadagain();
    }

    function categoryLoaded(data) {
        if (data.categories) {
            var tpl = '';
            for (var i = 0; i < data.categories.length; i++) {
                if (data.categories[i].term == 'Education') {
                    tpl += '<option value="' + data.categories[i].term + '" selected>' + data.categories[i].label + '</option>';
                } else {
                    tpl += '<option value="' + data.categories[i].term + '" >' + data.categories[i].label + '</option>';
                }
            }
            $("#category-node").html(tpl);
        }
    }
</script>

<div id="youku-upload">
    <div class="container">
        <form class="well form-horizontal" name="video-upload">
            <fieldset>
                <div class="control-group">
                    <label class="control-label" for="spanSWFUploadButton">选择文件：</label>
                    <div id="uploadControl" class="controls">

                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label" for="input01">标题：</label>
                    <div class="controls">
                        <input type="text" class="input-xlarge" id="input01" name="title">
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label" for="textarea">简介：</label>
                    <div class="controls">
                        <textarea class="input-xlarge" id="textarea" rows="3" name="description"></textarea>
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label" for="input02">标签：</label>
                    <div class="controls">
                        <input type="text" class="input-xlarge" id="input02" name="tags">
                        <span class="help-inline"></span>
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label" for="category-node">类别：</label>
                    <div class="controls">
                        <select id="category-node" name="category"></select>
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label">版权所有</label>
                    <div class="controls">
                        <label class="radio inline">
                            <input type="radio" name="copyright_type" id="copyright_type2" value="original" checked="">原创
                        </label>
                        <label class="radio inline"><input type="radio" name="copyright_type" id="copyright_type1" value="reproduced">转载</label>
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label">视频权限</label>
                    <div class="controls">
                        <label class="radio inline">
                            <input type="radio" name="public_type" id="public_type1" value="all" checked="">公开
                        </label>
                        <label class="radio inline">
                            <input type="radio" name="public_type" id="public_type2" value="friend">仅好友
                        </label>
                        <label class="radio inline">
                            <input type="radio" name="public_type" id="public_type3" value="password">输入密码观看
                        </label>
                        <label class="radio inline" style="display:none" id="passwrod">
                            <input type="text" class="input " name="watch_password">
                        </label>
                    </div>
                </div>
                <div class="form-actions">
                    <button type="submit" class="btn btn-primary start" id="btn-upload-start">
                        <i class="icon-upload icon-white"></i>
                        <span>开始上传</span>
                    </button>
                </div>
            </fieldset>
        </form>
        <div class="row">
            <div class="span5" id="upload-status-wraper"></div>
        </div>
        <br>
        <div class="well">
            <h3>说明</h3><ul><li>最大支持上传<strong>1 GB</strong> 视频文件</li><li>允许上传的视频格式为：wmv,avi,dat,asf,rm,rmvb,ram,mpg,mpeg,3gp,mov,mp4,m4v,dvix,dv,dat,</br>mkv,flv,vob,ram,qt,divx,cpk,fli,flc,mod。不符合格式的视频将会被丢弃，请确保视频格式的正确性，避免上传失败</li></ul>
        </div>
    </div>
    <div id="complete"></div>
    <div id="login" style="width:100%;height:100%;position:fixed;z-index:999;left:0px;top:0px;overflow:hidden;display:none;">
    </div>
</div>